package kayao.server.network.message;

import kayao.common.KayaoValues;
import kayao.common.NetworkUtils;
import kayao.server.GameManager;

public class NewMissionMessage extends Message {

	public NewMissionMessage(String targetAddress, int retries,
			int timeoutLength, int priority) {
		super(targetAddress, retries, timeoutLength, priority);
		createPacketData();
	}

	@Override
	public void createPacketData() {
		//[ MAGIC NUMBER (int32) | NEW_MISSION (b) | ID_MISSION (int32) | X (float) | Y (float) |Z (float) ]
		mSendData=new byte[4+1+4+4+4+4];
		int index=0;
		NetworkUtils.insertIntToByteArray(mSendData, index, KayaoValues.MAGIC_NUMBER);
		index+=4;
		mSendData[index]=KayaoValues.NEW_MISSION;
		index++;
		NetworkUtils.insertIntToByteArray(mSendData, index, GameManager.getCurrentMissionId());
		index+=4;
		System.arraycopy(GameManager.getPositionBytes(), 0, mSendData, index, 12);
	}

	@Override
	public String type() {
		return "NewMission";
	}

}
